package model.dao.registerOrder;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import log.MyLogger;
import db.dbconnection;

public class RequestCounter {

	
	String sql = "" ;
	 db.dbconnection dbconnection ;
	 java.sql.Connection myConnection ;
	 ResultSet rs ;
	 Statement st ;

	 
	public Integer countRequests() {
		try {
		    dbconnection = new dbconnection();
		    myConnection = dbconnection.getConnection();
		    st = myConnection.createStatement();
		    sql = "SELECT Count(*)+1 AS requests from service_request";
			rs = st.executeQuery(sql);
			rs.next();
				Integer requests=Integer.parseInt(rs.getString("requests"));

		    this.dbconnection.close();
		    return requests;
		} catch (SQLException e) {
			// logimine
//			MyLogger.Log("RequestCounter: countRequests(): ", e.getMessage());
		}
		return null;
	}
}
